class Solution {
    public int dayOfYear(String date) {
        int daysofMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        int day = Integer.parseInt(date.substring(8));
        int year = Integer.parseInt(date.substring(0, 4));
        if ((year % 400 == 0) || (year % 100 != 0 && (year % 4 == 0))) {
            daysofMonth[1]++;
        }
        int month = Integer.parseInt(date.substring(5, 7));
        for (int i = 0; i < month - 1; i++) {
            day += daysofMonth[i];
        }
        return day;
    }
}